﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BaseUnits;

namespace Carbon_Tracker
{
    public partial class frmSearchPowerUnit : Form
    {
        public frmSearchPowerUnit()
        {
            InitializeComponent();
        }

        private void frmSearchPowerUnit_Load(object sender, EventArgs e)
        {
            BaseUnits.Builders.PowerUnitBuilder pBuilder = new BaseUnits.Builders.PowerUnitBuilder(DatabaseInterface.Connection.Singleton);
            foreach (IPowerUnit p in pBuilder.getPowerUnits())
            {
                this.cmbPowerUnits.Items.Add(p);
            }
        }

        private void btnChange_Click(object sender, EventArgs e)
        {
            IPowerUnit p = (IPowerUnit)this.cmbPowerUnits.SelectedItem;
            if (p != null)
            {
                frmPowerUnitManager f = new frmPowerUnitManager(DatabaseInterface.Connection.Singleton, p);
                f.MdiParent = this.MdiParent;
                f.Show();
                this.Close();
                //f.WindowState = FormWindowState.Maximized;
            }
            else
            {
                MessageBox.Show("You must select a power unit to edit", "error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
            }
        }
    }
}
